package com.demo.send;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.demo.gather.GatherImpl;

public class ClientTest2 {

	public static void main(String[] args) {
		//创建线程池
		ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
		
		SendImpl send = new SendImpl();
		
		GatherImpl gather = new GatherImpl();
		//发布任务
		scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
			
			@Override
			public void run() {
				send.send(gather.gather());
			}
		}, 1, 600, TimeUnit.SECONDS);
		
		/*
		Timer timer = new Timer();

		SendImpl send = new SendImpl();
		
		GatherImpl gather = new GatherImpl();
		timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				send.send(gather.gather());
			}
		}, 1000, 5000);*/
	}
	

}
